/*
 * AutoCreateFromTemplateDialog.java
 *
 * Created on 9. Juni 2008, 23:08
 */

package twi.view;

import javax.swing.JInternalFrame;

import twi.query.QueryTemplate;

/**
 * 
 * @author Soeren
 */
public class AutoCreateFromTemplateDialog extends javax.swing.JDialog {

	private JInternalFrame[] frames;

	/**
	 * Creates new form AutoCreateFromTemplateDialog
	 * 
	 * @param queryTemplate
	 */
	public AutoCreateFromTemplateDialog(java.awt.Frame parent, boolean modal,
			QueryTemplate queryTemplate) {
		super(parent, modal);
		initComponents();
		this.frames = queryTemplate.createFrames();
		int x = 0;
		int y = 0;
		for (int i = 0; i < frames.length; i++) {
			frames[i].setLocation(x, y);
			x += 100;
			if (x > 300) {
				x = 0;
				y = 100;
			}
			jDesktopPane1
					.add(frames[i], javax.swing.JLayeredPane.DEFAULT_LAYER);
			frames[i].setResizable(true);
			frames[i].pack();
		}
	}

	/**
	 * This method is called from within the constructor to initialize the form.
	 * WARNING: Do NOT modify this code. The content of this method is always
	 * regenerated by the Form Editor.
	 */
	@SuppressWarnings("unchecked")
	// <editor-fold defaultstate="collapsed" desc="Generated
	// Code">//GEN-BEGIN:initComponents
	private void initComponents() {

		jDesktopPane1 = new javax.swing.JDesktopPane();
		jButton_cancel = new javax.swing.JButton();
		jButton_exec = new javax.swing.JButton();

		setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

		jDesktopPane1.setName("jDesktopPane1"); // NOI18N

		jButton_cancel.setText("cancel");
		jButton_cancel.setName("jButton_cancel"); // NOI18N
		jButton_cancel.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_cancelActionPerformed(evt);
			}
		});

		jButton_exec.setText("execute Query");
		jButton_exec.setName("jButton_exec"); // NOI18N
		jButton_exec.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton_execActionPerformed(evt);
			}
		});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																layout
																		.createSequentialGroup()
																		.addComponent(
																				jButton_cancel)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				jButton_exec))
														.addComponent(
																jDesktopPane1,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																593,
																Short.MAX_VALUE))));
		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												jDesktopPane1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												499,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																jButton_cancel)
														.addComponent(
																jButton_exec))));

		pack();
	}// </editor-fold>//GEN-END:initComponents

	private void jButton_cancelActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_jButton_cancelActionPerformed
		dispose();
	}// GEN-LAST:event_jButton_cancelActionPerformed

	private void jButton_execActionPerformed(java.awt.event.ActionEvent evt) {

	}

	// Variables declaration - do not modify//GEN-BEGIN:variables
	private javax.swing.JButton jButton_cancel;
	private javax.swing.JButton jButton_exec;
	private javax.swing.JDesktopPane jDesktopPane1;
	// End of variables declaration//GEN-END:variables

}
